<?php
namespace app\index\controller;

use app\common\controller\Base;
use app\common\controller\IndexBase;
use think\Db;
use think\Session;

class Index extends Base
{
    public function index()
    {
    	$userinfo = Session::get('userInfo');
    	$data = Db::name("Goods")->where("status",1)->order('sort desc')->select();
    	$is_shop = 0;
    	if($userinfo){
    		$is_shop = get_user_is_shop($userinfo['id']);
    	}
    	foreach ($data as $k => $v) {
    		if($is_shop == 0 && $v['type'] == 1){
    			$data[$k]['price'] = $v['first_price'];
    		}elseif($v['type'] == 2){
    			$data[$k]['price'] = $v['cz_price'];
    		}elseif($v['type'] == 3){
    			$data[$k]['price'] = $v['dl_price'];
    		}
    	}
        $banner = Db::name('banner')->where('status',1)->order('sort desc')->select();
        $this->assign('banner',$banner);
    	//print_r($this->userinfo['id']);exit;
        $this->titleName = "消费商城";
        $this->assign('data',$data);
        return $this->fetch();
    }
}
